﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp3_Grid
{
    /// <summary>
    /// Window4.xaml 的交互逻辑
    /// </summary>
    public partial class Window4 : Window
    {
        public Window4()
        {
            InitializeComponent();
        }

        private void companyTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeViewItem selectedNode = e.NewValue as TreeViewItem;
            if (selectedNode != null)
            {
                if (selectedNode.Header is string)
                {
                    treeNodeValue.Text = selectedNode.Header.ToString();
                }
                else if (selectedNode.Header is StackPanel)
                {
                    treeNodeValue.Text = ((selectedNode.Header as StackPanel).Children[0] as TextBlock).Text;
                }
            }
        }
    }
}
